package com.duanjw.java.proxy.custom;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class DuanjwInvocationHandler implements CustomInvocationHandler {
    private Object target;
    public DuanjwInvocationHandler(Object target) {
        this.target = target;
    }

    /**
     *
//     * @param proxy 代理对象
     * @param method 目标对象
     * @param args
     * @return
     * @throws Throwable
     */
    @Override
    public Object invoke(Method method, Object[] args) throws Throwable {
        System.out.println("我是植入的代码，调用了CustomInvocationHandler.invoke方法");
        return method.invoke(target, new Object[]{"哭哭哭"});
    }
}
